<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>Document</title>
</head>

<body>
	<script>

		var arr = [1,3,4,2]
		var target = 6
		function twoNums(arr, target) {
			let obj = new Map()
			for (let i = 0; i < arr.length; i++) {
				obj[arr[i]] = i
			}
			console.log(obj);
			for (let i = 0; i < arr.length; i++) {
				if (obj[target - arr[i]] && obj[target - arr[i]]!== i) {
					return [obj[target - arr[i]], i]
				}
			}
		}
		console.log(twoNums(arr, target));

	</script>
</body>

</html>